
var VIValue = 0;
function ReadChart3(series) {
    //ajax数据准备
    $.ajax({
        "url":"/cgi-bin/AXZMPY/LISQL.py",
        "datatype":"json",
        "type":"post",
        "complete":function(data){
        var Data = eval('('+data.responseText+')');
        VIValue = parseFloat(Data.info[0].State);  
     }
    });
}
 
function timer3(series) {
    ReadChart3(series);
    var x = (new Date()).getTime(); // current time
    series[0].addPoint([x, VIValue], true, true);
    setTimeout(function(){timer3(series);},5000);
}


$(function () {
    $(document).ready(function() {                                                  
        Highcharts.setOptions({                                                     
            global: {                                                               
                useUTC: false                                                       
            }                                                                       
        });
        var chart;  
        $('#LI_Y').highcharts({   
        	series: [{                                                              
                name: '实时粉尘浓度',                                                
                data: (function() {                                                 
                    // generate an array of random data                             
                    var data = [],                                                  
                        time = (new Date()).getTime(),                              
                        i;                                                          
                                                                                    
                    for (i = -50; i <= 0; i++) {                                    
                        data.push({                                                 
                            x: time + i * 1000,                                     
                            y: 0                                        
                        });                                                         
                    }                                                               
                    return data;                                                    
                })()                                                                
            }],
            chart: {  
            	hight:100,
            	weight:20,
                type: 'spline',                                                     
                animation: Highcharts.svg, // don't animate in old IE               
                marginRight: 10,                                                    
                events: {                                                           
                    load: function() {                                                                                      
                        // set up the updating of the chart each second             
                        //var series = this.series;
                        timer3(this.series);
                    }                                                               
                }                                                                   
            },                                                                      
            title: {                                                                
                text: '实时粉尘浓度曲线'                                            
            },                                                                      
            xAxis: {                                                                
                type: 'datetime',                                                   
                tickPixelInterval: 150                                              
            },                                                                      
            yAxis: {
            	tickInterval:1,
            	min:0,
            	max:15,
                title: {                                                            
                    text: 'VI浓度(ppm)'                                                   
                },                                                                  
                plotLines: [{                                                       
                    value: 0,                                                       
                    width: 1,                                                       
                    color: '#808080'                                                
                }]                                                                  
            },                                                                      
            tooltip: {                                                              
                formatter: function() {                                             
                        return '<b>'+ this.series.name +'</b><br/>'+                
                        Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) +'<br/>'+
                        Highcharts.numberFormat(this.y, 2);                         
                }                                                                   
            },
            //曲线图标位置属性设置
            legend: {                                                               
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'top',
                borderWidth: 0
            },                                                                      
            exporting: {                                                            
                enabled: false                                                      
            }                                                                      
        });                                                                         
    });                                                                             
                                                                                    
});                                   
